<!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<title>动态地绑定到它的 is 特性</title>
	<script src="vue.js"></script>
</head>
<body>
<div id="app">
  <button @click="change()">切换页面</button>
  <component :is="currentView"></component>
</div>
<script>
    var home = {template:'<div>打开主页</div>'};
    var login = {template:'<div>打开登录页面</div>'};
    var register = {template:'<div>打开注册页面</div>'};
    var vm=new Vue({
      el: '#app',
      components: {
        home,
        login,
        register,
      },
      data:{
        index:0,
        arr:['home','login','register'],
      },
      computed:{
        currentView(){
            return this.arr[this.index];
        }
      },
      methods:{
        change(){
          this.index = (++this.index)%3;
        }
      }
    })
</script>
</body>
</html>